<?php
/**
 * @authors alex (20779512@qq.com)
 * @date    2014-03-24 17:25:39
 * @version 1.0
 */

class IndexAction extends AdminAction {
    
    #首页
    public function index(){  
    	$obj = M('Order');

    	//当日订单
    	$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y')); 
		$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
		$map['createTime'] = array('between',array($beginToday,$endToday));
		$map['payStatus'] = 1;
		$todayOrder = $obj->where($map)->count();
		$todayMoney = $obj->where($map)->sum('money');
		if (!$todayMoney) {
			$todayMoney = 0;
		}
		$this->assign('todayOrder',$todayOrder);
		$this->assign('todayMoney',$todayMoney);

    	//当月订单
    	$beginMonth=date('Y-m-01', strtotime(date("Y-m-d")));
        $endMonth = date('Y-m-d', strtotime("$beginDate +1 month -1 day"));
        unset($map);
        $map['createTime'] = array('between',array(strtotime($beginMonth),strtotime($endMonth)));
        $map['payStatus'] = 1;
        $monthOrder = $obj->where($map)->count();
		$monthMoney = $obj->where($map)->sum('money');
		if (!$monthMoney) {
			$monthMoney = 0;
		}
		$this->assign('monthOrder',$monthOrder);
		$this->assign('monthMoney',$monthMoney);

    	//当年订单  
    	$beginYear = date("Y",time())."-01-01";
        $endYear = date("Y",time())."-12-31";	
        unset($map);
        $map['createTime'] = array('between',array(strtotime($beginYear),strtotime($endYear)));
        $map['payStatus'] = 1;
        $yearOrder = $obj->where($map)->count();
		$yearMoney = $obj->where($map)->sum('money');
		if (!$yearMoney) {
			$yearMoney = 0;
		}
		$this->assign('yearOrder',$yearOrder);
		$this->assign('yearMoney',$yearMoney);

		//待支付订单
		unset($map);
        $map['payStatus'] = 0;
        $nopayOrder = $obj->where($map)->count();
		$nopayMoney = $obj->where($map)->sum('money');
		if (!$nopayMoney) {
			$nopayMoney = 0;
		}
		$this->assign('nopayOrder',$nopayOrder);
		$this->assign('nopayMoney',$nopayMoney);

		//待支付订单
		unset($map);
        $map['payStatus'] = 1;
        $map['status'] = 0;
        $chuliOrder = $obj->where($map)->count();
		$chuliMoney = $obj->where($map)->sum('money');
		if (!$chuliMoney) {
			$chuliMoney = 0;
		}
		$this->assign('chuliOrder',$chuliOrder);
		$this->assign('chuliMoney',$chuliMoney);

		//今日提现申请
		unset($map);
		$map['createTime'] = array('between',array($beginToday,$endToday));
		$obj = M('Tixian');
		$todayTixian = $obj->where($map)->count();
		$todayTixianMoney = $obj->where($map)->sum('money');
		if (!$todayTixianMoney) {
			$todayTixianMoney = 0;
		}
		$this->assign('todayTixian',$todayTixian);
		$this->assign('todayTixianMoney',$todayTixianMoney);

		//待处理提现申请
		unset($map);
		$map['createTime'] = array('between',array($beginToday,$endToday));
		$map['status'] = 0;
		$chuliTixian = $obj->where($map)->count();
		$chuliTixianMoney = $obj->where($map)->sum('money');
		if (!$chuliTixianMoney) {
			$chuliTixianMoney = 0;
		}
		$this->assign('chuliTixian',$chuliTixian);
		$this->assign('chuliTixianMoney',$chuliTixianMoney);


    	$this->display();
    }

}